A library for converting json
to a table.
It uses https://github.com/zhiburt/tabled to build a table.
Usage
Add the library to a dependency list.
[]
= "*"
The main and only function you shall use to build a table is json_to_table
.
use json_to_table;
use json;
+-------------------------------------------------+
| +-------------+-------------------------------+ |
| | address | +---------+-----------------+ | |
| | | | city | Innsbruck | | |
| | | +---------+-----------------+ | |
| | | | country | Austria | | |
| | | +---------+-----------------+ | |
| | | | street | 32, Laham St. | | |
| | | +---------+-----------------+ | |
| +-------------+-------------------------------+ |
| | age | 23 | |
| +-------------+-------------------------------+ |
| | doj | 11-12-2019 | |
| +-------------+-------------------------------+ |
| | id | E00245 | |
| +-------------+-------------------------------+ |
| | married | false | |
| +-------------+-------------------------------+ |
| | name | Aleix Melon | |
| +-------------+-------------------------------+ |
| | referred-by | E0012 | |
| +-------------+-------------------------------+ |
| | role | +-------+ | |
| | | | Dev | | |
| | | +-------+ | |
| | | | DBA | | |
| | | +-------+ | |
| +-------------+-------------------------------+ |
+-------------------------------------------------+
You can also build a table in a squash mode.
use json_to_table;
use json;
+-------------+---------+---------------+
| address | city | Innsbruck |
| +---------+---------------+
| | country | Austria |
| +---------+---------------+
| | street | 32, Laham St. |
+-------------+---------+---------------+
| age | 23 |
+-------------+-------------------------+
| doj | 11-12-2019 |
+-------------+-------------------------+
| id | E00245 |
+-------------+-------------------------+
| married | false |
+-------------+-------------------------+
| name | Aleix Melon |
+-------------+-------------------------+
| referred-by | E0012 |
+-------------+-------------------------+
| role | Dev |
| +-------------------------+
| | DBA |
+-------------+-------------------------+
You can chose how to build an Array
and Object
via Orientation
.
use ;
use json;
+----------------------------------------------------+
| +------+---------------+-------------+-----------+ |
| | age | name | referred-by | role | |
| +------+---------------+-------------+-----------+ |
| | 23 | Aleix Melon | E0012 | +-------+ | |
| | | | | | Dev | | |
| | | | | +-------+ | |
| | | | | | DBA | | |
| | | | | +-------+ | |
| +------+---------------+-------------+-----------+ |
+----------------------------------------------------+
| +------+---------------+-------------+-----------+ |
| | age | name | referred-by | role | |
| +------+---------------+-------------+-----------+ |
| | 24 | Aleix Melon | E0012 | +-------+ | |
| | | | | | DBA | | |
| | | | | +-------+ | |
| +------+---------------+-------------+-----------+ |
+----------------------------------------------------+